var e = require("../../@babel/runtime/helpers/interopRequireDefault")(require("../../@babel/runtime/helpers/typeof")), t = require("../../1D8980678A52ABCF7BEFE860FD67FE64.js"), s = require("../../3F2EFC058A52ABCF59489402DCA7FE64.js"), n = require("../../A1901C218A52ABCFC7F674269787FE64.js"), o = getApp();

Component({
    properties: {
        item: {
            type: Object,
            value: {},
            observer: function(e, t) {
                this._myPropertyChange(e, t);
            }
        }
    },
    data: {
        banner: t.IMGPATH + "bdd.png",
        play: t.IMGPATH + "play.png",
        checkedIndex: "",
        selectIndex: 0,
        showResult: !1,
        isAdShow: !0,
        btnText: "查看结果"
    },
    attached: function() {
        var e = this.data.item, t = 0;
        e && "number" == typeof e.selected && (t = e.selected), e.selected = t, this.setData({
            selectIndex: t,
            item: e
        });
    },
    methods: {
        checkHandle: function(e) {
            var t = e.currentTarget.dataset.index, s = this.data.item, n = this.data.selectIndex, o = s.questionType;
            this.setData({
                checkedIndex: t
            });
            var i = {
                index: t
            };
            if ("number" == typeof s.selected && (i.order = n), "SCORE" == o) n == s.crossHeadList.length - 1 && this.setData({
                showResult: !0
            }); else if ("REDIRECT" == o) {
                s.crossHeadList[n].questionOptList[t].redirectSerialNum ? this.setData({
                    showResult: !1
                }) : this.setData({
                    showResult: !0
                });
            } else this.setData({
                showResult: !0
            });
            this.triggerEvent("changeIndex", i);
        },
        jumpPrev: function() {
            var e = this.data.item, t = e.questionType, s = this.data.selectIndex;
            "REDIRECT" == t ? (s = e.crossHeadList[s].prevNumber, this.triggerEvent("changeIndex", {
                index: e.crossHeadList[s].checked,
                prevStatus: !0,
                order: s
            })) : --s >= 0 && this.triggerEvent("changeIndex", {
                index: e.crossHeadList[s].checked,
                prevStatus: !0,
                order: s
            });
        },
        sendServiceReport: function(e) {
            var t = o.globalData.key, i = o.globalData.skey, a = "/msgCenter/income/cpm", r = (0, 
            s.generateSignature)(a), c = r.nonce, d = r.timestamp, l = {
                appKey: r.appKey,
                timestamp: d,
                nonce: c,
                signature: r.signature,
                key: t,
                skey: i
            };
            wx.request({
                url: n.thirdPartyDomain + a,
                data: l,
                method: "post",
                success: function(t) {
                    console.log(t), e();
                },
                fail: function(t) {
                    console.log(t), e();
                }
            });
        },
        jumpToAnswer: function() {
            var e = this.data, t = e.item;
            e.isAdShow;
            wx.setStorageSync("questionAnswer", t), wx.redirectTo({
                url: "/pages/answer/index"
            });
        },
        playAd: function(e) {
            var t = null;
            wx.createRewardedVideoAd && ((t = wx.createRewardedVideoAd({
                adUnitId: "adunit-a3e93e13e60bcc44"
            })).onError(function(t) {
                e && e(), console.log("videoAd onError", t);
            }), t.onLoad(function(e) {
                console.log("videoAd onLoad", e);
            }), t.onClose(function(t) {
                (t && t.isEnded || void 0 === t) && e && e(), console.log("videoAd onClose", t);
            }), t.load().then(function() {
                console.log("激励视频加载成功"), t.show().then(function() {
                    console.log("激励视频 广告显示成功");
                }).catch(function(t) {
                    e && e(), console.log("激励视频 广告显示失败");
                });
            }).catch(function(e) {
                console.log("激励视频加载失败");
            }));
        },
        _myPropertyChange: function(t, s) {
            var n = this;
            t && "number" == typeof t.selected && ((0, e.default)(t.crossHeadList[t.selected].checked) || console.log("还未选择答案"), 
            setTimeout(function() {
                n.setData({
                    selectIndex: t.selected
                });
            }, 300));
        }
    }
});